﻿@model IEnumerable<Peninsula.Site.Data.Models.MenuItem>
    @using Peninsula.Utility.Extensions

<li class="start">
    <a href="@Url.Action("Index","Home")">
        <i class="fa fa-home"></i>
        <span class="title">
            首页
        </span>
        <span class="selected">
        </span>
    </a>
</li>
@foreach (var menuItem in Model)
{
    <li class="@(menuItem.IsActive ? "active open" : "")">
        @{
            string url = (menuItem.Action.IsNullOrWhiteSpace() || menuItem.Controller.IsNullOrWhiteSpace())
                ? ""
                : Url.Action(menuItem.Action, menuItem.Controller);
        }
        <a href="@url">
            <i class="fa @menuItem.CssClass"></i>
            <span class="title">
                @menuItem.MenuItemName
            </span>
            @if (menuItem.ChildrensMenuItem.Any())
            {
                <span class="arrow"></span>
            }
        </a>
        @if (menuItem.ChildrensMenuItem.Any())
        {
            <ul class="sub-menu">
                @foreach (var subMenuItem in menuItem.ChildrensMenuItem)
                {
                    @Html.Partial("_MenuItem", subMenuItem)
                }
            </ul>
        }
    </li>
}